import book.Book;
import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main {
    public static User login(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的姓名");
        String name = scanner.nextLine();
        System.out.println("请输入您的权限 1>:管理员 0>:普通用户");
        int choice = scanner.nextInt();
        if(choice == 1){
            User user = new AdminUser();
            user.setName(name);
            return user;
        }else if(choice == 0){
            User user = new NormalUser();
            user.setName(name);
            return user;
        }else{
            return null;
        }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = null;
        while(true){
            user = login();
            if(user == null){
                System.out.println("输入错误,请重新输入");
            }else{
                break;
            }
        }
        while(true){
            user.menu();
            Scanner scanner = new Scanner(System.in);
            int choice = scanner.nextInt();
            user.callPosMethod(choice,bookList);
        }

    }
}
